﻿using Sage.DownloadLite.Utils;

namespace Sage.DownloadLite.Models
{
    /// <summary>
    /// 下载任务结果
    /// </summary>
    public class TaskResult
    {
        /// <summary>
        /// 任务信息
        /// </summary>
        public TaskInfo TaskInfo { get; set; } = new();
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; }
        /// <summary>
        /// 下载的文件路径
        /// </summary>
        public string? FilePath { get; set; }
        /// <summary>
        /// 文件大小（字节）
        /// </summary>
        public long FileSize { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        public Exception? Error { get; set; }
        /// <summary>
        /// 任务状态
        /// </summary>
        public Enums.TaskStatus Status { get; set; }
        /// <summary>
        /// 下载耗时
        /// </summary>
        public TimeSpan Duration { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }
        /// <summary>
        /// 错误消息
        /// </summary>
        public string? ErrorMessage => Error?.Message;
        /// <summary>
        /// 格式化的文件大小
        /// </summary>
        public string FormattedFileSize => BytesFormatter.Format(FileSize);
    }
}
